import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    user: {
      // id: '',
      uid: '',
      // roleId: '',
      // username: '',
      // password: '',
      // avatar: '',
      // loginDate: '',
      // createTime: ''
    },
    userInfo: {}
  },
  mutations: {
    setuser(state,user){
      state.user = user
    },
    setuserInfo(state,userInfo){
      state.userInfo = userInfo
    },
    sethobby(state,hobby){
      state.userInfo.hobby = hobby
    },
    setpoints(state,points){
      state.userInfo.points = points
    },
    setuserout(state,user){
      state.user = user
    }
  },
  actions: {
    setuser(context,user){
      context.commit('setuser',user)
    },
    setuserInfo(context,userInfo) {
       context.commit('setuserInfo',userInfo)
    },
    sethobby(context,hobby) {
      context.commit('sethobby',hobby)
    },
    setpoints(context,points) {
      context.commit('setpoints',points)
    },
    setuserout(context,user){
      context.commit('setuserout',user)
    }
  },
  getters: {},
  modules: {}
})

export default store
